/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package db2docbook;

/**
 *
 * @author alhshk
 */
public class Column {

  final private String colName;
  final private int dataType;
  final private String typeName;
  final private int colSize;
  final private boolean nullable;
  private Table table;

  public Column(String colName, int dataType, String typeName, int colSize, boolean nullable) {
    if (colName == null) {
      throw new NullPointerException("colName cannot be null");
    }
    this.colName = colName;
    this.dataType = dataType;
    this.typeName = typeName;
    this.colSize = colSize;
    this.nullable = nullable;
  }

  public String getColName() {
    return colName;
  }

  public int getColSize() {
    return colSize;
  }

  public int getDataType() {
    return dataType;
  }

  public boolean isNullable() {
    return nullable;
  }

  public String getTypeName() {
    return typeName;
  }

  void setTable(Table table) {
    this.table = table;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    final Column other = (Column) obj;
    if (!this.colName.equals(other.colName)) {
      return false;
    }
    return true;
  }

  @Override
  public int hashCode() {
    int hash = 7;
    hash = 53 * hash + this.colName.hashCode();
    return hash;
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();

    sb.append(colName);
    sb.append(", ");
    sb.append(dataType);
    sb.append(", ");
    sb.append(typeName);
    sb.append(", ");
    sb.append(colSize);
    sb.append(", ");
    sb.append(nullable);

    return sb.toString();
  }
}
